Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Manchester-NW5-Zaw Khing-JavaScript-Core-1-Week1#397

Open
zkhing wants to merge 8 commits into
CodeYourFuture:masterfrom
zkhing:master
Open

Manchester-NW5-Zaw Khing-JavaScript-Core-1-Week1#397
zkhing wants to merge 8 commits into
CodeYourFuture:masterfrom
zkhing:master

Conversation

@zkhing
Copy link
Copy Markdown

@zkhing zkhing commented Aug 26, 2022

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link
Copy Markdown

@Dominic-Taylor-Dev Dominic-Taylor-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good job - well done!


function trimWord(word) {
return wordtrim();
wordtrim = word.trim();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't really use this variable so could get away with just directly returning word.trim()


function getStringLength(word) {
return "word".length();
wordLength = word.length;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above - no need for separate variable

function multiply(a, b, c) {
a * b * c;
return;
var sum = a * b * c;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

function getRandomNumber() {
return Math.random() * 10;
function getRandomNumber() { //create function called getRandomNumber
return Math.random() * 10; //returns a random number between 0 and 9
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want an integer (whole number) then you will still need to round this down. To do that, you can use Math.floor() (see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)

Comment thread mandatory/4-tax.js

function calculateSalesTax() {}
function calculateSalesTax(productPrice) {
const salesTax = (productPrice / 100) * 20;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where you have numbers that don't inherently mean anything e.g. 20 here, it's often good to assign them to a variable to make their meaning clear in the code e.g.:

const SALES_TAX_RATE = 20;
const salesTax = (productPrice / 100) * SALES_TAX_RATE;

If you're wondering why the caps, you'll often see constants expressed like this in JavaScript

@@ -1,2 +1,14 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
var sum = numberOfStudents + numberOfMentors;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use let or const always and never var

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants